package com.itheima.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketDemo02 {
    public static void main(String[] args) throws IOException {
        //1.创建ServerSocket对象
        ServerSocket sc=new ServerSocket(8080);
        System.out.println(111);
        //2.监听客户端连接，返回一个Socker对象
        Socket accept=sc.accept();
        System.out.println(333);
        //3.获取输入流，读数据，显示在控制台
        InputStream inputStream = accept.getInputStream();
        int b;
        while ((b=inputStream.read())!=-1){
            System.out.println((char)b);
        }
        sc.close();
        accept.close();
        //4.释放
    }
}
